<template>
  <div class="HuikuiInfo el-card is-always-shadow el-card__body">
    <el-dialog
      title="回馈预览"
      :visible.sync="dialogVisible"
      @close="closed"
      width="950px"
      :close-on-click-modal="false">
      <avue-crud
        ref="crud"
        :option="optionTableOne"
        :data="listTable">
      </avue-crud>
      <avue-crud
        ref="crud"
        :option="optionTable"
        :data="listTable">
        <template slot="menuLeft">
          SC系统数据对比与回馈
        </template>
        <template slot-scope="scope" slot="replySellAmount">
          <el-input :disabled="showType==2" type="input" size="mini" v-model="replySellAmount"></el-input>
        </template>
        <template slot-scope="scope" slot="replyInvestAmount">
          <el-input :disabled="showType==2" type="input" size="mini" v-model="replyInvestAmount"></el-input>
        </template>
        <template slot-scope="scope" slot="replyFaretkAmount">
          <el-input :disabled="showType==2" type="input" size="mini" v-model="replyFaretkAmount"></el-input>
        </template>
      </avue-crud><br/><br/><br/>
      <avue-form :disabled="isReload" :option="option" v-model="formData" @submit="handleSubmit">
        <template  slot="jdReplyReason" slot-scope="scope">
          <el-select :disabled="showType==2" v-model="jdReplyReason" placeholder="请选择" style="width: 150px">
            <el-option
              v-for="(item,index) in jdReplyReasonList"
              :key="index"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="menuForm" >
          <el-button v-if="showType==1" type="primary" @click="handleSubmit" >确认</el-button>
          <el-button @click="closed" >返回</el-button>
        </template>
      </avue-form>
    </el-dialog>
  </div>
</template>


<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import ExportJsonExcel from "js-export-excel";
  import {fenExYuangettoFixed,getSysDictItemListToDict} from "../../../../../api/subwayRat/commonCheck";
  import {updateSwAuConductorHierarchyAmountDifferen} from "../../../../../api/stationTiecketManager/shuJuXieChaGuanLi/BOM/CJ/BOMCengJiCY";
  import ElInput from "../../../../../../node_modules/element-ui/packages/input/src/input";
  export default {
    components:{
      ElInput
    },
    data() {
      return {
        jdReplyReason :'',
        replySellAmount:0,
        replyInvestAmount:0,
        replyFaretkAmount:0,
        optionTableOne:{},
        listTable:[],
        optionTable:{},
        option:{},
        showType : 0,
        isReload:true,
        dialogVisible:true,
        formData:{},
        jdReplyReasonList:[]
      }
    },
    created() {
      getSysDictItemListToDict({"type":"JD_REPLY_REASON"}).then((response)=>{
        this.jdReplyReasonList = response.data.data;
      });
      this.getOption();
    },
    methods: {
      handleSubmit(){
        if(''==this.jdReplyReason){
          this.$message.warning("请选择回馈原因后提交！");
          return
        }
        let p = {
          id:this.formData.id,
          replySellAmount:this.replySellAmount,
          replyInvestAmount:this.replyInvestAmount,
          replyFaretkAmount:this.replyFaretkAmount,
          jdReplyReason:this.jdReplyReason,
          jdReplyDetail:this.formData.jdReplyDetail
        };
        updateSwAuConductorHierarchyAmountDifferen(p).then((response)=>{
        });
        this.$message.success('操作成功')
        this.$parent.getList();
        this.closed();
      },
      recallShow(row){
        this.replySellAmount = row.replySellAmount?(row.replySellAmount/100).toFixed(2):"0.00";
        this.replyInvestAmount = row.replyInvestAmount?(row.replyInvestAmount/100).toFixed(2):"0.00";
        this.replyFaretkAmount = row.replyFaretkAmount?(row.replyFaretkAmount/100).toFixed(2):"0.00";
        this.jdReplyReason = row.jdReplyReason;
        Object.assign(this.formData,row);
        this.listTable.push(row);

        if(1==this.showType){
          this.option.group[0].column[1].disabled = false;
        }
      },
      closed(){
        this.dialogVisible=false;
        this.$parent.isShowDia=false;
      },
      getOption(){
        this.showType = this.$parent.showType;
        if(1 == this.$parent.showType) {
          this.isReload = false;
        }
        this.optionTableOne={
          border: false,
          index: false,
          indexLabel: '序号',
          stripe: false,
          menuAlign: 'center',
          menu: false,
          viewBtn: false,
          editBtn: false,
          emptyBtn:false,
          delBtn: false,
          align: 'center',
          addBtn: false,
          column: [{
            label: '系统层级',
            prop: 'comparativeType',
            formatter:function(row, value , label, column){
              return value == 1?'SC':'LC';
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: 'SC售票金额',
            prop: 'sellAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'sellAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: '售票差异金额',
            prop: 'comparativeSelltkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'comparativeSelltkAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: 'SC充值金额',
            prop: 'investAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'investAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: '充值差异金额',
            prop: 'comparativeInvestAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'comparativeInvestAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: 'SC补票金额',
            prop: 'faretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'faretkAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: '补票差异金额',
            prop: 'comparativeFaretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'comparativeFaretkAmount');
            },
            search: false,
            hide: false,
          },{
            width: 120,
            label: '票款合计差异',
            prop: 'id',
            formatter:function(row, value , label, column){
              var num =(row.comparativeFaretkAmount + row.comparativeSelltkAmount + row.comparativeInvestAmount) / 100;
              num = num.toFixed(2);
              return num;
            },
            search: false,
            hide: false,
          }]
        };
        this.optionTable = {
          border: false,
          index: false,
          indexLabel: '序号',
          stripe: false,
          menuAlign: 'center',
          menu: false,
          viewBtn: false,
          editBtn: false,
          emptyBtn:false,
          delBtn: false,
          align: 'center',
          addBtn: false,
          column: [{
            label: '回馈售票金额',
            prop: 'replySellAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'replySellAmount');
            },
            slot:true,
            search: false,
            hide: false,
          },{
            label: '回馈充值金额',
            prop: 'replyInvestAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'replyInvestAmount');
            },
            slot:true,
            search: false,
            hide: false,
          },{
            label: '回馈补票金额',
            prop: 'replyFaretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'replyFaretkAmount');
            },
            slot:true,
            search: false,
            hide: false,
          }]
        };
        this.option={
          submitBtn:false,
          emptyBtn:false,
          group:[{
              icon:'',
              label: '',
              // collapse:false,
              prop: 'group',
              column: [{
                label: '机电专业回馈差异原因',
                prop: 'jdReplyReason',
                formslot : true,
                labelWidth:200
              },{
                label: '机电专业详细描述',
                prop: 'jdReplyDetail',
                disabled:true,
                type:'textarea',
                labelWidth:180
              }]
            }]
        }
      }
    },
    mounted() {
    }
  }
</script>
